package logic

import (
	"context"
	"rent-ease/models/mysql"
	"rent-ease/rentrpc/internal/svc"
	"rent-ease/rentrpc/rentrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RentListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RentListLogic {
	return &RentListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 列表
func (l *RentListLogic) RentList(in *rentrpc.RentListRequest) (*rentrpc.RentListResponse, error) {
	// todo: add your logic here and delete this line

	var list []*rentrpc.RentList

	list, err := mysql.RentList(mysql.DB)
	if err != nil {
		return nil, err
	}

	return &rentrpc.RentListResponse{
		List: list,
	}, nil
}
